Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add whitelistHosts option. #1451

Closed
wants to merge 7 commits into from
Closed

Conversation

dracos
Copy link

@dracos dracos commented Mar 13, 2018

For #1443

@CLAassistant
Copy link

CLAassistant commented Mar 13, 2018

CLA assistant check
All committers have signed the CLA.

## if we have white listed hosts
if wlh = config.whitelistHosts
## and url does not match any of our whitelisted hosts
if not matched = blacklist.matches(req.proxiedUrl, wlh)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused by the comment and whitelist / blacklist combination here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whitelist is being passed in to this function as wlh, this is just a (now badly named) function. blacklist (the library) is now more a *list-matching library after these changes so presumably should be renamed.

@bahmutov
Copy link
Contributor

@dracos I think the logic between white listed hosts and black listed should be expressed very clearly, also you can run unit tests to see them fail (as they are failing on CI)

cd packages/server
npm run test-unit

@jennifer-shehane
Copy link
Member

As gleb mentioned, some of the tests are failing. We also need tests to cover the whilelistHosts, specifically in this file: https://github.com/cypress-io/cypress/blob/issue-1350/packages/server/test/unit/config_spec.coffee#L488

Let us know if you have trouble getting the tests running locally.

@brian-mann
Copy link
Member

Also beyond unit tests, we must have e2e tests to cover this config option. You can take the existing blacklist e2e tests and repurpose them.

@dracos
Copy link
Author

dracos commented Mar 13, 2018

Have renamed library to hostlist, added unit and e2e tests that pass locally. Don't think the failure there now is in anything I've touched.

@brian-mann
Copy link
Member

Right that failure is not related.

@jennifer-shehane jennifer-shehane added the stage: needs review The PR code is done & tested, needs review label May 15, 2018
@itsravenous
Copy link

Any updates on this? A project I'm working on makes calls to a lot of external URLs and our blacklist is very long (and when new endpoints are added we have to remember to add them).

jennifer-shehane and others added 2 commits August 2, 2018 11:36
# Conflicts:
#	packages/server/lib/config.coffee
#	packages/server/lib/controllers/proxy.coffee
@jennifer-shehane jennifer-shehane requested review from a team and bahmutov and removed request for chrisbreiding, brian-mann and bahmutov July 2, 2019 05:44
@flotwig
Copy link
Contributor

flotwig commented Dec 19, 2019

This is something that can be accomplished once #687 is added. Here is one example of how:

function whitelistMatches(url) {
	// ...
}

cy.route('*', (req) => {
	if (!whitelistMatches(req.url)) {
		return req.destroy()
	}

	req.reply()
})

blacklistHosts will probably be deprecated at some point too, so I'll close this in favor of #687.

@flotwig flotwig closed this Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: needs review The PR code is done & tested, needs review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants